<?php
class StaffCarrersController extends AppController {

	var $name = 'StaffCarrers';

	function index() {
		$this->StaffCarrer->recursive = 0;
		$this->set('staffCarrers', $this->paginate());
	}

	function view($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid staff carrer', true));
			$this->redirect(array('action' => 'index'));
		}
		$this->set('staffCarrer', $this->StaffCarrer->read(null, $id));
	}

	function add() {
		if (!empty($this->data)) {
			$this->StaffCarrer->create();
			if ($this->StaffCarrer->save($this->data)) {
				$this->Session->setFlash(__('The staff carrer has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The staff carrer could not be saved. Please, try again.', true));
			}
		}
		$staffs = $this->StaffCarrer->Staff->find('list');
		$this->set(compact('staffs'));
	}

	function edit($id = null) {
		if (!$id && empty($this->data)) {
			$this->Session->setFlash(__('Invalid staff carrer', true));
			$this->redirect(array('action' => 'index'));
		}
		if (!empty($this->data)) {
			if ($this->StaffCarrer->save($this->data)) {
				$this->Session->setFlash(__('The staff carrer has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The staff carrer could not be saved. Please, try again.', true));
			}
		}
		if (empty($this->data)) {
			$this->data = $this->StaffCarrer->read(null, $id);
		}
		$staffs = $this->StaffCarrer->Staff->find('list');
		$this->set(compact('staffs'));
	}

	function delete($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid id for staff carrer', true));
			$this->redirect(array('action'=>'index'));
		}
		if ($this->StaffCarrer->delete($id)) {
			$this->Session->setFlash(__('Staff carrer deleted', true));
			$this->redirect(array('action'=>'index'));
		}
		$this->Session->setFlash(__('Staff carrer was not deleted', true));
		$this->redirect(array('action' => 'index'));
	}
}
?>